package com.ruoyi.edit.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.edit.domain.DevelopReviewItem;
import com.ruoyi.edit.service.IDevelopReviewItemService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 核检项目Controller
 * 
 * @author qiufeng
 * @date 2022-05-11
 */
@Controller
@RequestMapping("/system/developReviewItem")
public class DevelopReviewItemController extends BaseController
{
    private String prefix = "system/developReviewItem";

    @Autowired
    private IDevelopReviewItemService developReviewItemService;

    @GetMapping()
    public String DevelopReviewItem()
    {
        return prefix + "/developReviewItem";
    }


    @GetMapping("/idByList")
    public String idByList(String developId, ModelMap mmap)
    {
        mmap.put("developId", developId);
        return prefix + "/developReviewItem";
    }
    /**
     * 查询核检项目列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DevelopReviewItem developReviewItem)
    {
        startPage();
        List<DevelopReviewItem> list = developReviewItemService.selectDevelopReviewItemList(developReviewItem);
        return getDataTable(list);
    }

    /**
     * 导出核检项目列表
     */
    @Log(title = "核检项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DevelopReviewItem developReviewItem)
    {
        List<DevelopReviewItem> list = developReviewItemService.selectDevelopReviewItemList(developReviewItem);
        ExcelUtil<DevelopReviewItem> util = new ExcelUtil<DevelopReviewItem>(DevelopReviewItem.class);
        return util.exportExcel(list, "核检项目数据");
    }

    /**
     * 新增核检项目
     */
    @GetMapping("/add")
    public String add(String developId, ModelMap mmap)
    {
        mmap.put("developId", developId);
        return prefix + "/add";
    }

    /**
     * 新增保存核检项目
     */
    @Log(title = "核检项目", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DevelopReviewItem developReviewItem)
    {
        return toAjax(developReviewItemService.insertDevelopReviewItem(developReviewItem));
    }

    /**
     * 修改核检项目
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        DevelopReviewItem developReviewItem = developReviewItemService.selectDevelopReviewItemById(id);
        mmap.put("developReviewItem", developReviewItem);
        return prefix + "/edit";
    }

    /**
     * 修改保存核检项目
     */
    @Log(title = "核检项目", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DevelopReviewItem developReviewItem)
    {
        return toAjax(developReviewItemService.updateDevelopReviewItem(developReviewItem));
    }

    /**
     * 删除核检项目
     */
    @Log(title = "核检项目", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(developReviewItemService.deleteDevelopReviewItemByIds(ids));
    }

    public static void main(String[] args) {
        String[] ids =  "childrenIds".split(",");
        System.out.println(ids);
    }
}
